import 'dart:convert' show json;

class Init {

  int time;
  List<String> ai;
  List<Host> host;
  List<Note> note;

  Init.fromParams({this.time, this.ai, this.host, this.note});

  factory Init(jsonStr) => jsonStr == null ? null : jsonStr is String ? Init.fromJson(json.decode(jsonStr)) : Init.fromJson(jsonStr);

  Init.fromJson(jsonRes) {
    time = jsonRes['time'];
    ai = jsonRes['ai'] == null ? null : [];

    for (var aiItem in ai == null ? [] : jsonRes['ai']){
      ai.add(aiItem);
    }

    host = jsonRes['host'] == null ? null : [];

    for (var hostItem in host == null ? [] : jsonRes['host']){
      host.add(hostItem == null ? null : Host.fromJson(hostItem));
    }

    note = jsonRes['note'] == null ? null : [];

    for (var noteItem in note == null ? [] : jsonRes['note']){
      note.add(noteItem == null ? null : Note.fromJson(noteItem));
    }
  }

  @override
  String toString() {
    return '{"time": $time, "ai": $ai, "host": $host, "note": $note}';
  }
}

class Note {

  Object state;
  String platform;
  String ver;

  Note.fromParams({this.state, this.platform, this.ver});

  Note.fromJson(jsonRes) {
    state = jsonRes['state'];
    platform = jsonRes['platform'];
    ver = jsonRes['ver'];
  }

  @override
  String toString() {
    return '{"state": $state, "platform": ${platform != null?'${json.encode(platform)}':'null'}, "ver": ${ver != null?'${json.encode(ver)}':'null'}}';
  }
}

class Host {

  int price;
  int uid;
  int vip;
  String birth;
  String code;
  String country;
  String icon;
  String nickname;

  Host.fromParams({this.price, this.uid, this.vip, this.birth, this.code, this.country, this.icon, this.nickname});

  Host.fromJson(jsonRes) {
    price = jsonRes['price'];
    uid = jsonRes['uid'];
    vip = jsonRes['vip'];
    birth = jsonRes['birth'];
    code = jsonRes['code'];
    country = jsonRes['country'];
    icon = jsonRes['icon'];
    nickname = jsonRes['nickname'];
  }

  @override
  String toString() {
    return '{"price": $price, "uid": $uid, "vip": $vip, "birth": ${birth != null?'${json.encode(birth)}':'null'}, "code": ${code != null?'${json.encode(code)}':'null'}, "country": ${country != null?'${json.encode(country)}':'null'}, "icon": $icon, "nickname": ${nickname != null?'${json.encode(nickname)}':'null'}}';
  }
}